// 闭包补充例子1

var makeCounter = function () {
    var privateCounter = 0;

    function changeBy(val) {
        privateCounter += val;
    }
    return {
        increment: function () {
            changeBy(1);
        },
        decrement: function () {
            changeBy(-1);
        },
        value: function () {
            console.log(privateCounter);
            return privateCounter;
        }
    }
};

var counter = makeCounter();
counter.value();
counter.increment();
counter.value();
counter.decrement();
counter.value();